﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Trippy.CollidableGameComponents;
using Trippy.CollidableGameComponents.Agents;
using Trippy.Levels;
using Trippy.CollidableGameComponents.Projectiles;

namespace Trippy.Abilities
{
    class Fire : Ability
    {
        public Fire(Level level) : base (level)
        {
            name = "Fire";
            icon = CurrentLevel.Game.Content.Load<Texture2D>("Sprites/Ability Icons/fire");
        }

        public override void OnAdd()
        {
            State = AbilityState.Available;
        }

        public override void OnActivate()
        {
            Fireball f = new Fireball(CurrentLevel);
            if (CurrentLevel.Hero.Sprite.CurrentMode == 0) //facing left
            {
                f.Position = new Vector2(CurrentLevel.Hero.BoundingBox.Left - 40f, CurrentLevel.Hero.Position.Y);
                f.Velocity = new Vector2(-200f, 0f);
            }
            else
            {
                f.Position = new Vector2(CurrentLevel.Hero.BoundingBox.Right + 40f, CurrentLevel.Hero.Position.Y);
                f.Velocity = new Vector2(200f, 0f);
            }
            f.Acceleration = CurrentLevel.Hero.Acceleration;
            f.MarkForAddition();

            SetTimer(3.0f);
            State = AbilityState.Unavailable;
            base.OnActivate();
        }

        protected override void OnTimer()
        {
            State = AbilityState.Available;
            base.OnTimer();
        }
    }
}
